package cn.wsn2018.tools.util;
import cn.wsn2018.tools.model.Log.LogsInfo;

import java.util.List;

/**
 * @author gmz.
 * @date 2018/12/16.
 * @time 15:20
 */
public class PageModel<T> {
    //结果集
    private List<T> datas;
    //查询记录数
    private int rowCount;
    //每页显示最大条数
    private int pageSize;
    //第几页
    private int pageNum;
    //跳过几条数
    private int skip = 0;
    //当前页的查询结果数
    private int datasSize = 0;

    public PageModel() {
    }

    /**
     * 获得总页数
     * @return
     */
    public int getTutolPages(){
        return ((int)rowCount + pageSize - 1)/pageSize;
    }

    public List<T> getDatas(){
        return datas;
    }

    public void setDatas(List<T> datas){
        this.datas = datas;
    }

    public int getRowCount(){
        return rowCount;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getSkip() {
        skip = (pageNum-1)*pageSize;
        return skip;
    }

    public void setSkip(int skip) {
        this.skip = skip;
    }

    public void setRowCount(int rowCount) {
        this.rowCount = rowCount;
    }

    public int getDatasSize() {
        return datasSize;
    }

    public void setDatasSize(List<LogsInfo> list) {
        this.datasSize = list.size();
    }

    /*
    *//**
     * 取得首页
     *//*
    public int getTopPageNo(){
        return 1;
    }

    *//**
     * 上一页
     *//*
    public int getPreviousPageNo(){
        if(pageIndex <= 1){
            return 1;
        }
        return pageIndex-1;
    }

    *//**
     * 下一页
     *//*
    public int getNextPageNo(){
        if(pageIndex>=getBottomPageNo()){
            return getBottomPageNo();
        }
        return pageIndex+1;
    }

    *//**
     * 取得尾页
     * @return
     *//*
    public int getBottomPageNo(){
        return getPages();
    }*/
}
